function showLaneConfigSearch() {
	window.location.href = "showLaneConfigSearch.do";
}

function ajaxFindLaneConfigSearchList(currentPage,pageSize) {
	$.ajax({
		type : "post",
		url : "ajaxLaneConfigSearchList.do",
		data:{
			configname:$("#txtConfigName").val(),
			canvia:$("#lstCanVia").val(),
			vehiclegroupid:$("#lstVehicleGroup").val(),
			currentPage:currentPage,
			pageSize:pageSize,
			orderBy:"id",
			},
		success : function(msg) {
			$("#listLaneConfigBox").html(msg);
		}
	});
}
	
function ajaxShowLaneConfigEdit(id){
	$.ajax({
		type:"post",
		url:"ajaxShowLaneConfigEdit.do",
		data:{laneConfigId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 700,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons: [
				          {
				        	  text: "保存",
				        	  click: function() {
				        		  ajaxSaveLaneConfig(this);
				        	  }
				          },
				          {
				        	  text: "关闭",
				        	  click: function() {
				        		  $(this).dialog( "close" );
				        	  }
				          }
				          ]
			});
		}
	});
}

function ajaxSaveLaneConfig(objDialog) {
	laneConfigValidate();
	if ($("#frmLaneConfig").valid()) {
		$(objDialog).dialog("close");
		var options ={
				type: "post",
				url : "ajaxSaveLaneConfig.do",
				success: function (msg) {
					clearInput("#sltLaneConfig");
					ajaxFindLaneConfigSearchList();
					showMessageDialog("保存车道配置信息","车道配置信息保存成功。",null,dialogType.info);
				}
		};
		$("#frmLaneConfig").ajaxSubmit(options);
	}
}

function ajaxShowLaneConfigView(id){
	$.ajax({
		type:"post",
		url:"ajaxShowLaneConfigView.do",
		data:{laneConfigId:id},
		success:function(msg){
			$("#dialog").html(msg);
			$("#dialog").dialog({
				autoOpen: true,
				width: 670,
				title:$(".dialogtitle").attr("title"),
				modal: true,
				buttons : [ {
					text : "关闭",
					click : function() {
						$(this).dialog("close");
					}
				} ]
			});
		}
	});
}

function ajaxDeleteLaneConfigById(id) {
	var laneConfigIds="";
	var sltLCF = $("#listLaneConfigList tbody input:checked").length;
	if(id==null){
		$("#listLaneConfigList tbody input:checked").each(function(){ 
			laneConfigIds += $(this).val()+";";
		});
		if(sltLCF == 0){
			showMessageDialog("提示","请选择一行或多行",null,dialogType.info);
			return;
		}else{
			laneConfigIds = laneConfigIds.substring(0, laneConfigIds.length-1);
		} 
	}else{
		laneConfigIds=id;
		sltLCF = 1;
	}
	if( laneConfigIds!=null){
		showMessageDialog("删除车道配置信息","确定要删除所选“"+sltLCF+"”条车道配置信息记录吗？",
				function () {
			$.ajax({     
				type:"post",
				url:"ajaxDeleteLaneConfigByIds.do",
				data:{laneConfigIds:laneConfigIds},
				success:function(msg){
					ajaxFindLaneConfigSearchList();
					showMessageDialog("提示","车道配置信息删除成功",null,dialogType.info);
				}
			});
		}
		,dialogType.warning);
	}
}

function laneConfigValidate(){
	$("#frmLaneConfig").validate({
		errorLabelContainer: $("#infoLaneConfig"),
		rules : {
			configname : {
				required :true				
			},
			canvia : {
				required :true				
			},
			vehiclegroupid : {
				required :true				
			}
		},
		messages : {
			configname : {
				required :"请输入名称！"
			},
			canvia : {
				required :"请输入是否可通行！"
			},
			vehiclegroupid : {
				required :"请输入机动车分组！"
			}
		},
		success: function(label) {
			label.html("&nbsp;");
		}
	});
}
